using System.Collections.Generic;
using OneSignalPush.MiniJSON;
using UnityEngine;

public class OneSignalAndroid : OneSignalPlatform
{
	private static AndroidJavaObject mOneSignal;

	public OneSignalAndroid(string gameObjectName, string googleProjectNumber, string appId, OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel)
	{
		mOneSignal = new AndroidJavaObject("com.onesignal.OneSignalUnityProxy", gameObjectName, googleProjectNumber, appId, (int)logLevel, (int)visualLevel);
	}

	public void SetLogLevel(OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel)
	{
		mOneSignal.Call("setLogLevel", (int)logLevel, (int)logLevel);
	}

	public void SendTag(string tagName, string tagValue)
	{
		mOneSignal.Call("sendTag", tagName, tagValue);
	}

	public void SendTags(IDictionary<string, string> tags)
	{
		mOneSignal.Call("sendTags", Json.Serialize(tags));
	}

	public void GetTags()
	{
		mOneSignal.Call("getTags");
	}

	public void DeleteTag(string key)
	{
		mOneSignal.Call("deleteTag", key);
	}

	public void DeleteTags(IList<string> keys)
	{
		mOneSignal.Call("deleteTags", Json.Serialize(keys));
	}

	public void IdsAvailable()
	{
		mOneSignal.Call("idsAvailable");
	}

	public void FireNotificationReceivedEvent(string jsonString, OneSignal.NotificationReceived notificationReceived)
	{
		Dictionary<string, object> dictionary = Json.Deserialize(jsonString) as Dictionary<string, object>;
		Dictionary<string, object> additionalData = null;
		if (dictionary.ContainsKey("custom"))
		{
			additionalData = dictionary["custom"] as Dictionary<string, object>;
		}
		notificationReceived((string)dictionary["alert"], additionalData, (bool)dictionary["isActive"]);
	}

	public void OnApplicationPause(bool paused)
	{
		if (paused)
		{
			mOneSignal.Call("onPause");
		}
		else
		{
			mOneSignal.Call("onResume");
		}
	}

	public void RegisterForPushNotifications()
	{
	}

	public void EnableVibrate(bool enable)
	{
		mOneSignal.Call("enableVibrate", enable);
	}

	public void EnableSound(bool enable)
	{
		mOneSignal.Call("enableSound", enable);
	}
}
